package com.lambda;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import lombok.Data;

public class TestAdd {
public static void main(String[] args) {
	List<MyObj> list = new ArrayList<>();
	for(int i=1;i<=10;i++) {
		MyObj o = new MyObj();
		o.setCode(i%3 + "");
		o.setVal(new BigDecimal(i));
		list.add(o);
	}
	System.out.println(list);
	Map<String, BigDecimal> partNoMap = list.stream().collect(Collectors.toMap(MyObj::getCode, MyObj::getVal, BigDecimal::add));
	System.out.println(partNoMap);
	
}

}

@Data
class MyObj {
	private String code;
	private BigDecimal val;
}
